package com.some;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;

public class QiAnXin01 {

    ArrayList<List<Integer>> lists = new ArrayList<>();
    ArrayDeque<Integer> stack = new ArrayDeque<>();
    public int DagPathNum (int[][] nodes) {
        // write code here
        stack.offerLast(0);
        dfs(nodes, 0, nodes.length-1);
        return lists.size();
    }
    public void dfs(int[][] nodes, int x,int n){
        if (x==n){
            lists.add(new ArrayList<Integer>(stack));
            return;
        }
        for (int i : nodes[x]) {
            stack.offerLast(i);
            dfs(nodes, i, n);
            stack.pollLast();
        }
    }

    public static void main(String[] args) {

    }
}
